package projectodedalo.servlets;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import projectodedalo.excepcion.DAOExcepcion;
import projectodedalo.modelo.Idea;
import projectodedalo.modelo.Usuario;
import projectodedalo.negocio.GestionIdea;
import projectodedalo.negocio.GestionUsuario;



/**
 * Servlet implementation class EvaluarIdeaServlet
 */
@WebServlet("/EvaluarIdeaServlet")
public class EvaluarIdeaServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public EvaluarIdeaServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		 
	String idIdea = request.getParameter("id");	
	System.out.println("EvaluarIdeaServlet doGet " + idIdea );
	
	GestionIdea negIdea = new GestionIdea();
	GestionUsuario negUsuario = new GestionUsuario();
	try {
		Idea vo = negIdea.obtener(idIdea);
		ArrayList<Usuario> l_asesores = negUsuario.obtieneAsesoresDisponibles();	
		System.out.println("EvaluarIdeaServlet: Almacena datos para el JSP");
		request.setAttribute("vo", vo);
		request.setAttribute("l_asesores", l_asesores);
	} catch (DAOExcepcion e) {
		System.out.println(e.getMessage());
		RequestDispatcher rd = request.getRequestDispatcher("error.jsp");
		rd.forward(request, response);
	}
	RequestDispatcher rd = request.getRequestDispatcher("evaluarIdea.jsp");
	rd.forward(request, response);

	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
